﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
using web_api.Models;

namespace web_api.ValidationAttributes {
  public class EmployeeNoMustDifferentFromFirstNameAttribute :ValidationAttribute{
    protected override ValidationResult IsValid(object value, ValidationContext validationContext) {
      var addDto = (EmployeeAddOrUpdateDto)validationContext.ObjectInstance;
      if (addDto.EmployeeNo == addDto.FirstName) {
        return new ValidationResult(ErrorMessage, new[] { nameof(EmployeeAddOrUpdateDto) });
      }
      return ValidationResult.Success;
    }
  }
}
